<template>
	<view class="container">
		<view class="title">
			{{newsdata.title}}
		</view>
		<view class="author">
			<view class="newstype">
				新闻类别：{{newsdata.type}}
			</view>
			<view class="postdata">
				发表日期：{{newsdata.date}}
			</view>
		</view>
		<view class="content">
			{{newsdata.content}}
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				"newsdata": {
					"id": 4,
					"title": "时事新闻2",
					"content": "时事新闻2内瓤",
					"type": "时事",
					"date": "2024-03-01"
				}
			}
		},
		methods: {

		},
		onLoad(opt) {
			uni.request({
				url: 'http://localhost:8090/foodapp/news/findone',
				method: 'POST',
				data: {"id":opt.id},
				success: res => {
					if (res.data.success) {
						this.newsdata = res.data.data
					} else {
						uni.showToast({
							title: '失败',
							icon:'none'
						}); 
					}
				},
				fail: () => {
					uni.showToast({
						title: '网络错误',
						icon: 'none'
					});
				},
				complete: () => {}
			});
		}
	}
</script>

<style>
.container{
	padding: 20px;
	font-size: 14px;
	line-height: 24px;
}
.title{
	width: 100%;
	text-align: center;
	font-size: large;
}
.author{
	display: flex;
	flex-direction: row;
	
	justify-content: space-between;
}
.content{
	text-indent: 2em;
}
</style>
